package demo;


import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.PrintWriter;
import java.io.Serializable;

@Component
public class FileLogger implements Serializable {
    public PrintWriter out;

    /**
     * 输出流资源初始化
     * @throws Exception
     */
    @PostConstruct
    public void open()throws Exception{
        out = new PrintWriter("File.txt");
        System.out.printf("打开text文件");
    }

    /**
     * 输出流关闭
     */

   // @PostConstruct
    public void close(){
        out.close();
        System.out.printf("关闭txt文件");
    }
}
